<template>
  <div class="div">
    <div class="l-content">
      <!-- 按钮 -->
      <el-button
        style="margin-right: 20px"
        @click="handleMenu"
        icon="el-icon-menu"
        size="mini"
      ></el-button>
      <!-- 面包屑 -->
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item
          v-for="item in tag"
          :key="item.path"
          :to="{ path: item.path }"
          >{{ item.label }}
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <!-- 头像-下拉框 -->
      <el-dropdown>
        <span class="el-dropdown-link">
          <img class="user" src="../assets/images/user.png" alt="" />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
// 使用vuex的辅助函数mapState拿到
import { mapState } from 'vuex'
export default {
  data () {
    return {}
  },
  methods: {
    handleMenu () {
      this.$store.commit('collapseMenu')
    }
  },
  computed: {
    ...mapState({
      // 它定义了如何将 Vuex 的 state 映射到组件的计算属性
      tag: state => state.tab.tabsList
    })
  }
}
</script>

<style lang="less" scoped>
.div {
  display: flex;
  height: 100%;
  justify-content: space-between;
  align-items: center;
  .l-content {
    display: flex;
    align-items: center;
  }
  .r-content {
    .user {
      width: 40px;
      height: 40px;
      border-radius: 50%;

      .el-dropdown-link {
        cursor: pointer;
        color: #409eff;
      }
    }
  }
}
</style>
